import java.net.Socket;
import java.util.HashMap;

public class ClientCenter {

	private HashMap<String, Client> m_IdToClient;
	private static ClientCenter m_ClientCenter;

	public static ClientCenter createClientCenter() {
		if (m_ClientCenter == null)
			m_ClientCenter = new ClientCenter();
		return m_ClientCenter;
	}

	private ClientCenter() {
		m_IdToClient = new HashMap<String, Client>();
	}

	public Client createClient(String id, Socket socket) {

		if (m_IdToClient.containsKey(id) == false) {
			Client client = new Client(id, socket);
			m_IdToClient.put(id, client);
		}
		return m_IdToClient.get(id);
	}
	
	public Client findClient(String id){
		if(m_IdToClient.containsKey(id))
			return m_IdToClient.get(id);
		return null;
	}

}
